'use client';
import {Button} from "@/components/Button"
import {Input} from "@/components/Input"
import {Textarea} from "@/components/Textarea"
import {UserInfo,SessionProvider} from "@/app/UserInfo";
import {useEffect} from "react"
import { redirect } from "next/navigation"
import {getServerSession} from "@/server/auth";
import {trpcClient, trpcClientReact} from "@/utils/api";
export default  function Home() {
    //2-1、默认失败会尝试5次，再Error
    // const {data,isLoading,isError} = trpcClientReact.hello.useQuery()
    //2-2、修改默认失败会尝试5次，再Error
    const {data,isLoading,isError} = trpcClientReact.hello.useQuery(
        void 0,//无参数
        {
            refetchOnWindowFocus: false,//关闭切换回来刷新接口
            refetchInterval: 1000,//离开多久刷新一次
            refetchOnReconnect: false,//网络变化的时候
        }
        )
  return (
    <div className="h-screen flex justify-center items-center">
      <form className="w-full max-w-md flex flex-col gap-4">
          <h1 className="text-center text-2xl font-bold">Create App</h1>
        <Input name="name" placeholder="App name"></Input>
        <Textarea name="description" placeholder="Description"></Textarea>
        <Button type="submit">submit</Button>
          {data?.hello}
          {isLoading && 'Loading...'}
          {isError && 'isError...'}

      </form>
        <SessionProvider>
            <UserInfo></UserInfo>
        </SessionProvider>
    </div>
  );
}
